package com.theaf.core.utils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * 流操作工具类.
 * @author songwenke
 * @date 2015-11-20
 *
 */
public class StreamHelper {

	private static int OFF =0;
	private static int LEN = 1024;
	
	public static byte[] read(InputStream in) throws IOException
	{
		int size = -1;
		int maxSize = 1024;
		byte[] bytes = new byte[maxSize];
		//StringBuffer buff = new StringBuffer();
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		//String s = null;
		while( (size =  in.read(bytes,OFF,LEN)) != -1 )
		{
			out.write(bytes,0,size);
		}
		return  out.toByteArray();
	}
}
